<template>
<div class="head-icons">
    <swiper class="swiper-content" :options="swiperOption" >
        <swiper-slide v-for="(page, index) of pages" :key="index">
            <div class="icon" v-for="item of page" :key="item.id">
                <img class="icon-img" :src="item.url"/>
                <div class="icon-font">热门景点</div>
            </div>
        </swiper-slide>
    </swiper>
</div>
</template>
<script>
export default {
  name: 'HomeIcons',
  data () {
    return {
      swiperOption: {

      },
      dataList: [
        {
          id: 1,
          url: 'http://img1.qunarzz.com/piao/fusion/1803/95/f3dd6c383aeb3b02.png',
          name: '热点门票'
        },
        {
          id: 2,
          url: 'http://mp-piao-admincp.qunarzz.com/mp_piao_admin_mp_piao_admin/admin/20194/5ea666792b98f34c86faea912b5fbcf9.png',
          name: '热点门票'
        },
        {
          id: 3,
          url: 'http://img1.qunarzz.com/piao/fusion/1803/95/8246f27355943202.png',
          name: '热点门票'
        },
        {
          id: 4,
          url: 'http://img1.qunarzz.com/piao/fusion/1803/95/f3dd6c383aeb3b02.png',
          name: '热点门票'
        },
        {
          id: 5,
          url: 'http://img1.qunarzz.com/piao/fusion/1803/95/f3dd6c383aeb3b02.png',
          name: '热点门票'
        },
        {
          id: 6,
          url: 'http://img1.qunarzz.com/piao/fusion/1803/95/f3dd6c383aeb3b02.png',
          name: '热点门票'
        },
        {
          id: 7,
          url: 'http://img1.qunarzz.com/piao/fusion/1803/95/f3dd6c383aeb3b02.png',
          name: '热点门票'
        },
        {
          id: 8,
          url: 'http://img1.qunarzz.com/piao/fusion/1803/95/f3dd6c383aeb3b02.png',
          name: '热点门票'
        },
        {
          id: 9,
          url: 'http://img1.qunarzz.com/piao/fusion/1803/95/f3dd6c383aeb3b02.png',
          name: '热点门票'
        }
      ]
    }
  },
  computed: {
    pages () {
      const pages = []
      this.dataList.forEach((item, index) => {
        const page = Math.floor(index / 8)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  }

}
</script>
<style scoped>

.head-icons >>> .swiper-container{
    width: 100%;
    height: 0;
    padding-bottom: 50%;
    background-color: #fff;
}
.swiper-wrapper,.swiper-slide{
    height: 0;
    padding-bottom: 50%;
     display: flex;
    flex-wrap: wrap;
}
.icon{
   width: 25%;
   height: 0;
   padding-bottom: 25%;
   display: flex;
   flex-direction: column;
   align-items: center;
}
.icon-img{
    width: 1rem;
    height: 1rem;
    margin-top: 0.15rem;
}
.icon-font{
    font-size: 0.15rem;
    margin-top: 0.2rem;
    color: #333333;
}
</style>
